package com.projectCommon.util.commonUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimestampConverter {

    public static void main(String[] args) {
        String timeString = "Sun, 31 Mar 2024 02:20:01 GMT";
        long timestamp = convertToTimestamp(timeString);
        System.out.println("Timestamp: " + timestamp);
    }

    public static long convertToTimestamp(String timeString) {
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
            Date date = sdf.parse(timeString);
            return date.getTime() / 1000; // 时间戳通常是以秒为单位
        } catch (Exception e) {
            e.printStackTrace();
            return 0;
        }
    }
}